var LevelFail = {
    _util: new Util(),
    _manage: null,
    _refer: null,
    init: function(){
        this._util.onAssignCCBMemberVariable(this.assignActive());
        var layerNode = this._util.newLayerFromCCB(s_levelFail_ccbi, this._refer);
        this._manage = this._util.ccbReader.getAnimationManager();
        this._manage.setCompletedAnimationCallback(this, this.onCCBAnimEnd);
        
        if (layerNode != null) {
            this._refer.addChild(layerNode, 2);
        }
        
    },
    onEnter: function(refer){
        cc.log("level_fail -> onEnter")
        this._refer = refer;
        this._refer.pauseLevelPlay();
        this.init();
        this.outAction = null;
    },
    onMainmenu: function(){
        var $this = this;
        this._manage.runAnimations("Out");
        var layer = SelectLevelLayer.create();
        this.outAction = function(){
            $this._refer.exitLevel();
            game.enterSelectLevels();
        }
    },
    onRetry: function(){
        var $this = this;
        this._manage.runAnimations("Out");
        this.outAction = function(){
            $this._refer.resumeLevel();
            $this._refer.retryLevel();
        }
    },
    assignActive: function(){
        var arr = new Array();
        var $this = this;
        arr.push({
            key: "btnRetry",
            callback: function(){
                sound.playButtonSound();
                $this.onRetry();
            }
        });
        arr.push({
            key: "btnMainmenu",
            callback: function(){
                sound.playButtonSound();
                $this.onMainmenu();
            }
        });
        return arr;
    },
    outAction: null,
    onCCBAnimEnd: function(){
        var animName = this._manage.getLastCompletedSequenceName();
        if (animName == "Out") {
            if (this.outAction != null) {
                this.outAction();
            }
        }
    }
}
